package com.easondongh.blog.dao;

import com.easondongh.blog.pojo.BlogCollection;
import com.easondongh.blog.pojo.Comment;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author EasonDongH
 * @date 2020/4/8 21:40
 */
@Repository
public interface BlogCollectionDao extends MongoRepository<BlogCollection,String> {

    /**
     * 根据用户id和博客id查询
     * @param userId
     * @param blogId
     * @return
     */
    int countByUserIdAndBlogId(Integer userId, String blogId);

    /**
     * 统计该用户的总收藏数
     * @param userId
     * return
     */
    int countByUserId(Integer userId);

    /**
     * 分页查询该用户的收藏
     * @param pageable
     * @return
     */
    Page<BlogCollection> findByUserIdOrderByCollectionTimeDesc(Integer userId, Pageable pageable);
}
